import { Injectable } from '@nestjs/common'
import { In, Repository } from 'typeorm'
import { Roles as RolesEntity } from 'src/entityAll/entities/Roles'
import { InjectRepository } from '@nestjs/typeorm'

@Injectable()
export class RoleService {
  constructor(
    @InjectRepository(RolesEntity)
    private readonly roleRepo: Repository<RolesEntity>,
  ) {}
  async getRolePermissions(roleIds: number[] | string[], systemId?: any) {
    // this.roleRepo.find
    return ['admin', 'user']
  }

  /**
   *
   * @param roleIds 角色ID列表
   * @returns 角色信息列表
   * @description 根据角色ID列表获取角色信息 - 启用状态的
   */
  async getRoleByIds(roleIds: number[]) {
    const roles = await this.roleRepo.find({
      where: {
        id: In(roleIds),
        status: 1,
      },
    })
    return roles
  }
}
